package com.ruoyi.web.controller.dispatch;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.DispatchPumpGroups;
import com.ruoyi.system.service.IDispatchPumpGroupsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 泵组信息Controller
 * 
 * @author ruoyi
 * @date 2025-03-02
 */
@RestController
@RequestMapping("/system/dispatchPumpGroups")
public class DispatchPumpGroupsController extends BaseController
{
    @Autowired
    private IDispatchPumpGroupsService dispatchPumpGroupsService;

    /**
     * 查询泵组信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchPumpGroups:list')")
    @GetMapping("/list")
    public TableDataInfo list(DispatchPumpGroups dispatchPumpGroups)
    {
        startPage();
        List<DispatchPumpGroups> list = dispatchPumpGroupsService.selectDispatchPumpGroupsList(dispatchPumpGroups);
        return getDataTable(list);
    }

    /**
     * 导出泵组信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchPumpGroups:export')")
    @Log(title = "泵组信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DispatchPumpGroups dispatchPumpGroups)
    {
        List<DispatchPumpGroups> list = dispatchPumpGroupsService.selectDispatchPumpGroupsList(dispatchPumpGroups);
        ExcelUtil<DispatchPumpGroups> util = new ExcelUtil<DispatchPumpGroups>(DispatchPumpGroups.class);
        util.exportExcel(response, list, "泵组信息数据");
    }

    /**
     * 获取泵组信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchPumpGroups:query')")
    @GetMapping(value = "/{pumpGroupId}")
    public AjaxResult getInfo(@PathVariable("pumpGroupId") Long pumpGroupId)
    {
        return success(dispatchPumpGroupsService.selectDispatchPumpGroupsByPumpGroupId(pumpGroupId));
    }

    /**
     * 新增泵组信息
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchPumpGroups:add')")
    @Log(title = "泵组信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DispatchPumpGroups dispatchPumpGroups)
    {
        return toAjax(dispatchPumpGroupsService.insertDispatchPumpGroups(dispatchPumpGroups));
    }

    /**
     * 修改泵组信息
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchPumpGroups:edit')")
    @Log(title = "泵组信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DispatchPumpGroups dispatchPumpGroups)
    {
        return toAjax(dispatchPumpGroupsService.updateDispatchPumpGroups(dispatchPumpGroups));
    }

    /**
     * 删除泵组信息
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchPumpGroups:remove')")
    @Log(title = "泵组信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{pumpGroupIds}")
    public AjaxResult remove(@PathVariable Long[] pumpGroupIds)
    {
        return toAjax(dispatchPumpGroupsService.deleteDispatchPumpGroupsByPumpGroupIds(pumpGroupIds));
    }
}
